<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/Public/layui/css/layui.css" media="all">
    <script src="/Public/layui/layui.js" charset="utf-8"></script>
    <style type="text/css">
        .select {
            display: inline;
        }
    </style>
</head>
<body style="background-color: #fff;">

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;text-align: center;font-family: kaiti;">
    <legend>修改班级信息</legend>
</fieldset>

<div style="width: 500px; margin: 15px auto;padding: 15px;border: 2px solid #666;background-color: #fff;">
    <form  action="/index.php/Admin/Class/update" method="post">
        <div class="layui-form-item" style="width: 400px;">
            <label class="layui-form-label">班级编号</label>
            <input type="hidden" name="class_id"  value=<?php echo ($class_id); ?>>
            <div class="layui-input-block" style="padding-top: 10px">
                <?php echo ($class_id); ?>
            </div>
        </div>

        <div class="layui-form-item" style="width: 400px;">
            <label class="layui-form-label">班级名称</label>
            <div class="layui-input-block">
                <input type="text" name="class_name" class="layui-input" value="<?php echo ($class_name); ?>" id="c_name">
            </div>
        </div>

        <div class="layui-form-item" style="width: 400px;">
            <label class="layui-form-label">学生人数</label>
            <div class="layui-input-block">
                <input type="text" name="student_number" class="layui-input" value="<?php echo ($student_number); ?>" id="s_num">
            </div>
        </div>

        <div class="layui-form-item"  style="width: 400px;">
            <label class="layui-form-label">专业</label>
                <!--添加隐藏域-->
                <input type="hidden" name="select" id="hidden_major_value" value=<?php echo ($major_name); ?>>
                <select name="major_name" id="major" lay-filter="aihao" class="col-a" id="major">
                    <option value=""></option>
                    <?php if(is_array($major_info)): foreach($major_info as $key=>$major): ?><option value="<?php echo ($major["major_name"]); ?>"><?php echo ($major["major_name"]); ?></option><?php endforeach; endif; ?>
                </select>
        </div>

        <div class="layui-form-item"  style="width: 400px;">
            <label class="layui-form-label">学院</label>
                <!--添加隐藏域-->
                <input type="hidden" name="select" id="hidden_college_value" value=<?php echo ($college_name); ?>>
                <select name="college_name" id="college" lay-filter="aihao" class="col-a" id="college">
                    <option value=""></option>
                    <?php if(is_array($college_info)): foreach($college_info as $key=>$college): ?><option value="<?php echo ($college["college_name"]); ?>"><?php echo ($college["college_name"]); ?></option><?php endforeach; endif; ?>
                </select>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="note" placeholder="添加备注" class="layui-textarea"><?php echo ($note); ?></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="submit" value="确定" class="layui-btn" id="sure">
                <!-- <button type="reset" class="layui-btn" >重置</button> -->
                <a href="http://www.sinon.com/index.php/Admin/class/index" class="layui-btn">取消</a>
            </div>
        </div>
    </form>
</div>
</body>
</html>

<script>
    //设置院系
    var count_college = $("#college option").length;
    var college_text = $("#hidden_college_value").val();
    for (var i = 0; i < count_college; i++) {
        if ($("#college ").get(0).options[i].text == college_text) {
            $("#college ").get(0).options[i].selected = true;
            break;
        }
    }
    //设置专业
    var count = $("#major option").length;
    var major_text = $("#hidden_major_value").val();
    for (var i = 0; i < count; i++) {
        if ($("#major ").get(0).options[i].text == major_text) {
            $("#major ").get(0).options[i].selected = true;
            break;
        }
    }
    //设置职称
    var count_title = $("#title option").length;
    var title_text = $("#hidden_title_value").val();
    for (var i = 0; i < count_title; i++) {
        if ($("#title ").get(0).options[i].text == title_text) {
            $("#title ").get(0).options[i].selected = true;
            break;
        }
    }

    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');
    });

    $('#sure').on('click', function(){
        var cna = $('#c_name').val();
        var num = $('#s_num').val();
        var major = $('#major').val();
        var col = $('#college').val();

        if(isNaN(num)){
            layer.msg('学生人数是数字哦！');
            return false;
        }

        if(cna==''||major==''||num==''||col==''){
            layer.msg('请填写完整数据');
            return false;
        }
    }); 

    $(document).ready(function(){
        $('input').attr('autocomplete', 'off'); 
    })
</script>

<style>
    .layui-form-select .layui-edge {
        position: absolute;
        right: 60px;
        top: 50%;
        margin-top: -3px;
        cursor: pointer;
        border-width: 6px;
        border-top-color: #c2c2c2;
        border-top-style: solid;
        transition: all .3s;
        -webkit-transition: all .3s;
    }
    .layui-input, .layui-textarea {
        display: block;
        width: 250px;
        padding-left: 10px;
    }
    .layui-form-select dl dd, .layui-form-select dl dt {
        padding: 6px 21px;
        line-height: 35px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .layui-form-select dl {
        left: 100px;
        min-width: 62%;
    }

    .col-a{
        padding-right: 30px;
        cursor: pointer;
        border-color: #D2D2D2!important;
        display: block;
        width: 250px;
        padding-left: 10px;
        height: 38px;
        line-height: 1.3;
        border-width: 1px;
        border-style: solid;
        background-color: #fff;
        border-radius: 2px;
    }

</style>

</body>
</html>